<?php

// +----------------------------------------------------------------------
// | H1CMS © OpenSource CMS
// +----------------------------------------------------------------------
// | Copyright (c) 2014-2016 http://www.h1cms.com All rights reserved.
// | Copyright (c) 2014-2016 嘉兴领格信息技术有限公司，并保留所有权利。
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: Allen <allen@lg4.cn>
// +----------------------------------------------------------------------

namespace h1cms\model;

use h1cms\system\Model;
use Lg\Database\Query;

/**
 * Node
 *
 * @author Allen <allen@lg4.cn>
 *
 * @property int $node_id Node Id
 */
class Module extends Model {

	public $table = 'modules';
	public $primaryKey = 'module_id';

	public static function getAll($filters = []) {
		$query = Query::table('modules');
		if (array_key_exists('module_id', $filters)) {
			$query->where('module_id', $filters['module_id']);
		} 
                if (array_key_exists('mod_type', $filters)) {
			$query->where('mod_type', $filters['mod_type']);
		}
                if (array_key_exists('pagesize', $filters)) {
			$query->limit(array_get($filters, 'pagesize', 20), array_get($filters, 'offset', 0));
		}
		if (array_key_exists('order_by', $filters)) {
			$query->orderBy(array_get($filters, 'order_by'));
		}

		return $query->getAll();
	}

}
